<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            模具维护模板列表
        </div>
    </header>
    <script id="chkBillTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="setTask('{{= it[index].sysid }}','{{= it[index].code }}','{{= it[index].name }}');">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-inner ">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            {{= it[index].code }} : {{= it[index].name }}
                        </div>
                    </div>
                </div>
            </div>
        </li>
        {{~}}

    </script>

    <div class="aui-content" style="margin-top:50px;">
        <div class="aui-form" style="margin-top:15px;">
            <div class="aui-content aui-margin-b-15">
                <ul class="aui-list aui-form-list">
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-item-label" style="font-size: 17px;">模板编码</div>
                            <input type="text" class="aui-input" placeholder="请输入模板编码"
                                style="width: 80%;font-size: 14px;" id="code">
                        </div>
                    </li>
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-item-label" style="font-size: 17px;">模板名称</div>
                            <input type="text" class="aui-input" placeholder="请输入模板名称"
                                style="width: 80%;font-size: 14px;" id="name">
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div style="width:100%;margin-top:2%;"></div>
    <div class="aui-btn aui-btn-info aui-btn-block" onclick="doSearch()">查询</div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="taskList">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var boxnum = "";
    var type = ""
    var rsCode = ""
    apiready = function () {
        type = api.pageParam.type;
        rsCode = api.pageParam.equipCode;
    };

    //查询模板
    function doSearch() {

        var code = $("#code").val();
        var name = $("#name").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getRsChkTemplate";
        var data = {
            values: {
                name: name,
                un: un,
                code: code,
                rsClass: '模具',
                type: type,
                rsCode: rsCode,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    if (list.length > 0) {
                        var evaluation = doT.template($api.dom('#chkBillTemp').innerHTML);
                        $api.dom('#taskList').innerHTML = evaluation(list);
                    } else {
                        api.toast({
                            msg: "该模具没有对应的维护模板",
                            duration: 3000
                        });
                    }


                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //选则返回函数
    function setTask(Tsysid, Tcode, Tname) {
        api.closeWin();
        var name = api.pageParam.name;
        api.execScript({
            name: 'rsMntTaskPlanmold',
            script: 'setTask("' + Tsysid + '","' + Tcode + '","' + Tname + '")'
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>